import VueRouter from "vue-router";
import Vue from "vue";
import Child from "@/components/Child.vue";
import Movediv from "@/components/layout/movedivkuang/movediv.vue";
import Intokenajax from "@/components/layout/fzaxios/intokenajax.vue";
import chatpage from "@/components/layout/chat/chatpage.vue";
import Test from "@/components/test.vue";
import Login from "@/components/layout/chat/login.vue";
import Cesium_1 from "@/components/layout/cesium/cesium_1.vue";
import Civil from "@/components/layout/civil/civil.vue";
import ShiShijiance from "@/components/layout/civil/children/shiShijiance.vue";
import ZiDianWeiHu from "@/components/layout/civil/children/ziDianWeiHu.vue";
import XiTongziDian from "@/components/layout/civil/children/table/box/xiTongziDian.vue";
import XiTongQuYu from "@/components/layout/civil/children/table/box/xiTongQuYu.vue";
import XiTongSheShi from "@/components/layout/civil/children/table/box/xiTongSheShi.vue";
import drawer from "@/components/layout/drawer/drawerpage.vue";
Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => {
    if (err.name !== "NavigationDuplicated") {
      // 只忽略重复导航错误
      throw err;
    }
  });
};

export default new VueRouter({
  routes: [
    {
      path: "/",
      name: "Child",
      component: Child,
    },
    {
      path: "/movediv",
      name: "movediv",
      component: Movediv,
    },
    {
      path: "/intokenajax",
      name: "intokenajax",
      component: Intokenajax,
    },
    {
      path: "/chatpage",
      name: "chatpage",
      component: chatpage,
    },
    {
      path: "/login",
      name: "login",
      component: Login,
    },
    {
      path: "/cesium",
      name: "cesium",
      component: Cesium_1,
    },
    {
      path: "/civil",
      name: "civil",
      component: Civil,
      redirect: "/civil/shiShijiance",
      children: [
        {
          path: "shiShijiance",
          name: "shiShijiance",
          component: ShiShijiance,
        },
        {
          path: "zidianweihu",
          name: "zidianweihu",
          component: ZiDianWeiHu,
          redirect: "/civil/zidianweihu/xitongziDian",
          children: [
            {
              path: "xitongziDian",
              name: "xitongziDian",
              component: XiTongziDian,
            },
            {
              path: "xitongquyu",
              name: "xitongquyu",
              component: XiTongQuYu,
            },
            {
              path: "xitongsheshi",
              name: "xitongsheshi",
              component: XiTongSheShi,
            },
          ],
        },
      ],
    },
    {
      path: "/drawerpage",
      name: "drawerpage",
      component: drawer,
    },
    {
      path: "/test",
      name: "test",
      component: Test,
    },
  ],
});
